﻿using BaseData.API.Read.Applications.DoctorScheduling.Command;
using BaseData.Domain.HospitalInformation;
using BaseData.ErrorCode;
using BaseData.Infrastructure.Interfaces;
using MediatR;

namespace BaseData.API.Read.Applications.DoctorScheduling.CommandHandler
{
    public class GetDoctorCommandHandler:IRequestHandler<GetDoctorComamnd,ApiResult<List<Doctors>>>
    {
        /// <summary>
        /// 医生仓储
        /// </summary>
        private readonly IBaseRepository<Doctors> baseRepository;

        public GetDoctorCommandHandler(IBaseRepository<Doctors> baseRepository)
        {
            this.baseRepository = baseRepository;
        }

        /// <summary>
        /// 查询医生列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task<ApiResult<List<Doctors>>> Handle(GetDoctorComamnd request, CancellationToken cancellationToken)
        {
            ApiResult<List<Doctors>> result=new ApiResult<List<Doctors>>();
            result.Code = ApiEnum.查询成功;
            result.Message = ApiEnum.查询成功.ToString();
            var list=baseRepository.GetAll();
            result.Data = list.ToList();
            return Task.FromResult(result);
        }
    }
}
